package com.dhj.streamTest;

import com.dhj.streamTest.entity.Author;

import java.util.List;

import static com.dhj.streamTest.entity.AuthorList.getAuthors;

public class Demo1 {


    public static void main(String[] args) {
        //打印所有年龄小于18的作家的名字，并且要注意去重
        List<Author> authors = getAuthors();
        authors.
                stream()//把集合转换成流
                .distinct()//先去除重复的作家
                .filter(author -> author.getAge() < 18)//筛选年龄小于18的
                .forEach(author -> System.out.println(author.getName()));//遍历打印名字

    }


}
